<template>
    <div>
        <t-header></t-header>
        <div class="info-bg"></div>
        <div class="w">
            <div class="info-wrap" v-if="acticleInfoData != ''">
                <div class="info-title">{{acticleInfoData.title}}</div>
                <div v-html="acticleInfoData.text"></div>
            </div>
        </div>
    </div>
</template>

<script>
import Header from '../components/global/Header';
import { onMounted, ref } from '@vue/composition-api';
import axios from 'axios';
export default {
    components: {
        't-header': Header
    },
    setup(props, context) {
        axios.defaults.baseURL = 'http://47.105.157.158:3000';
        onMounted(() => {
            getActicleInfo(context.parent.$route.params.id);
        })

        // 文章详情数据
        const acticleInfoData = ref('');
        // 获取文章详情数据
        const getActicleInfo = async function (id) {
            let { data: res } = await axios.get(`/user/acticleinfo/${id}`);
            if (res.status != 200)
                return context.parent.$message.error('获取文章详情数据失败，请后退重试');
            acticleInfoData.value = res.theInfo;
        }   


        const methods = {}

        return {
            ...methods,
            acticleInfoData
        }
    }
}  
</script>

<style lang="less" scoped>
.info-bg {
    height: 300px;
    background: url('../assets/images/user.jpg') no-repeat;
    background-size: cover;
}

.info-wrap {
    padding-top: 20px;
    position: absolute;
    left: 50%;
    top: -100px;
    transform: translateX(-50%);
    width: 100%;
    background-color: #fff;
    box-shadow: 0 0 10px #fff;
    border-radius: 8px;
}

.info-title {
    font-size: 26px;
    color: #999;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}
</style>